home *** CD-ROM | disk | FTP | other *** search
/ PC & Mediji 1998 February / PCM_9802.iso / programi / director / data.z / Behavior Library.cst / 00024_Script_Image Cycle Cast Members < prev    next >
Text File  |  1997-05-09  |  5KB  |  155 lines

  1. -- Image Cycle Members
  2.  
  3.  
  4. -- n state cycling, bounce list
  5. -- relies on cast members being contiguous
  6. -- exports SetState and CycleState
  7. -- if receives a CycleState event, it checks it's name and increments the state
  8.  
  9.  
  10.  
  11. property Enabled
  12. property MemberMin, MemberMax, ImageCastLib, MemberRefMin, MemberRefMax
  13. property CycleStyle  -- cycling, bouncing
  14. -- memberMin and memberMax are actually membernumbers, as is currentstate
  15.  
  16. property goingDown   -- TRUE  if going through the list in reverse order
  17. --                      FALSE if traversing the list normally
  18.  
  19. property CurrentState
  20. property NumStates
  21.  
  22. property name
  23.  
  24. on CycleState me, name
  25.   if name = the name of me then
  26.     bumpstate_intern me
  27.   end if 
  28. end
  29.  
  30. on SetState me, statenum
  31.   if the enabled of me then
  32.     if statenum > the numstates of me then 
  33.       set statenum = the numstates of me
  34.     else if statenum < 1 then 
  35.       set statenum = 1
  36.     end if
  37.     set the member of sprite the spritenum of me = ¼
  38.             member ( the membermin of me + statenum - 1 ) of castLib imageCastLib
  39.   end if
  40. end
  41.  
  42. on setGoingDown me, value
  43.   set the goingDown of me to value
  44. end
  45.  
  46. on SetCycleStyle me, value
  47.   set the CycleStyle of me to value
  48. end
  49.  
  50. ---
  51.  
  52.  
  53. on bumpstate_intern me
  54.   if the enabled of me then
  55.     if ( the CycleStyle of me = #Repeat ) then 
  56.       if NOT the goingDown of me then -- going Up
  57.         set curr = the currentstate of me  + 1
  58.         if curr > the numstates of me then 
  59.           set curr = 1
  60.         end if
  61.       else -- going Down
  62.         set curr = the currentstate of me  - 1
  63.         if curr < 1 then set curr = the numstates of me
  64.       end if
  65.       
  66.     else   -- Reverse cycle
  67.       if NOT the goingDown of me then -- going Up 
  68.         set curr = the currentstate of me  + 1
  69.         if curr > the numstates of me then
  70.           set curr = curr - 2
  71.           set the goingDown of me = TRUE
  72.         end if
  73.       else   -- going Down
  74.         set curr = the currentstate of me  - 1
  75.         if curr < 1 then
  76.           set curr = 2
  77.           set the goingDown of me = FALSE
  78.         end if
  79.       end if
  80.     end if
  81.     
  82.     set the currentstate of me = curr
  83.     setstate me, curr
  84.   end if  
  85. end
  86.  
  87. on BeginSprite me
  88.   set the enabled of me = TRUE
  89.   set the membermin of me = the membernum of member memberRefMin
  90.   set the membermax of me = the membernum of member memberRefMax
  91.   
  92.   set the numstates of me = (the membermax of me) - (the membermin of me) + 1
  93.   
  94.   set the currentState of me = ( the memberNum of sprite the spriteNum of me ) - ¼
  95.                                  the MemberMin of me + 1
  96.   set the imageCastLib of me = the number of castLib ¼
  97.                                        ( the castLibNum of sprite ( the spriteNum of me ))
  98.   setstate me, the currentstate of me
  99. end
  100.  
  101. on getPropertyDescriptionList
  102.   if the currentspritenum = 0 then 
  103.     set memdefault = 0 
  104.   else
  105.     
  106.     set memref = the member of sprite the currentspritenum
  107.     set castlibnum = the castlibnum of memref
  108.     set memdefault = member (the membernum of member memref + 1) of castlib castlibnum
  109.   end if
  110.   
  111.   set p_list = [ ¼
  112.           #Name: [ #comment:   "Item Name:", ¼
  113.                     #format:   #symbol, ¼
  114.                    #default:   #MultiState_1 ], ¼
  115.      #MemberRefMin: [ #comment:   "First Image:", ¼
  116.                     #format:   #graphic, ¼
  117.                    #default:    memref ], ¼
  118.      #MemberRefMax: [ #comment:   "Last Image:", ¼
  119.                     #format:   #graphic, ¼
  120.                    #default:    memdefault ], ¼
  121.     #CycleStyle: [ #comment:   "Cycle Style:", ¼
  122.                     #format:   #symbol, ¼
  123.                      #range: [ #Repeat, #Reverse ], ¼
  124.                    #default:   #Repeat ], ¼
  125.      #GoingDown: [ #comment:   "Reverse Order:", ¼
  126.                     #format:   #boolean, ¼
  127.                    #default:    FALSE ] ¼
  128.                  ]
  129.   return p_list  
  130.   
  131. end
  132.  
  133. on getBehaviorDescription
  134.   return ¼
  135. "Makes the sprite cycle through a range of cast members when the CycleState message is received." & RETURN & ¼
  136. "PARAMETERS:" & RETURN & ¼
  137. "ò Item Name - (optional) Enter an item name to identify the current sprite so that it can receive a specific message. Do not use spaces. Use the name as an argument for the Message Sprite or Message All Sprites behaviors."  & RETURN & ¼
  138. "ò First Image - Enter the name of the first cast member in the cycling range."  & RETURN & ¼
  139. "ò Last Image  - Enter the name of the last cast member in the cycling range."  & RETURN & ¼
  140. "ò Cycle Mode - Choose Repeat to repeat the same sequence.  Choose Reverse to cycle back through the sequence in reverse order." & RETURN & ¼
  141. "ò Reverse Order - Turn this option on to proceed from the last to the first image by default."  & RETURN & ¼
  142. "MESSAGES:" & RETURN & ¼
  143. "ò CycleState - Switches the sprite's cast member to the next image in the sequence." & RETURN & ¼
  144. "ò SetState state_number - Advances directly to the position in the sequence identified by state_number."
  145.   
  146. end
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.